import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import get from '@dfeidao/atom-mobile/local/get';
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
import show_sheet from '@dfeidao/atom-mobile/msgbox/action-sheet';
import toast from '@dfeidao/atom-mobile/msgbox/toast';
export default async function a006(fd: IFeidaoAiMobile) {
	const class_res = get(fd, 'class_res') as [{ class_id: string, class_name: string, grade: string }];
	const options = new Array();
	for (let i = 0; i < class_res.length; i++) {
		const text = class_res[i].grade + '-' + class_res[i].class_name;
		options.push(text);
	}
	options.push('取消');
	const res = await show_sheet({
		options,
		title: '                                      选择签退班级'
	});
	const class_s = class_res[res];
	if (!class_s) {
		return;
	}
	// 签退
	const param = get(fd, 'params') as {
		teacher_name: string;
		productid: string;
		teacher_no: string;
	};
	const params = { productid: param.productid, teacher_name: param.teacher_name, teacher_no: param.teacher_no } as {
		teacher_name: string,
		productid: string,
		teacher_no: string,
		class_id: string,
		class_name: string
	};
	params.class_id = class_s.class_id;
	params.class_name = class_s.class_name;
	const d = await nodejs<{ code: number, msg: string }>('app-home/s004', {
		params
	});
	if (d.code) {
		toast({
			type: 'success',
			text: d.msg,
			position: 'top'
		});
	} else {
		toast({
			type: 'danger',
			text: d.msg,
			position: 'top'
		});

	}
}
